﻿using System;
using System.Windows;
using System.Windows.Media;

namespace BezierApproximations.ViewModels
{
    public class PointViewModel : BindableBase
    {
        private Point center;
        private Point topLeft;
        private double diameter;
        private SolidColorBrush color;

        public PointViewModel(Point center)
            : this(center, 10)
        {
        }

        public PointViewModel(Point center, double diameter)
        {
            this.Diameter = diameter;
            this.Center = center;
            this.Color = new SolidColorBrush(Colors.Black);
        }

        public SolidColorBrush Color
        {
            get
            {
                return this.color;
            }
            set
            {
                if (this.color != value)
                {
                    this.color = value;
                    this.OnPropertyChanged("Color");
                }
            }
        }

        public Point Center
        {
            get
            {
                return this.center;
            }
            set
            {
                if (this.center != value)
                {
                    this.center = value;
                    this.OnPropertyChanged("Center");
                    this.TopLeft = new Point(value.X - this.Diameter/2, value.Y - this.Diameter/2);
                }
            }
        }

        public Point TopLeft
        {
            get
            {
                return this.topLeft;
            }
            set
            {
                if (this.topLeft != value)
                {
                    this.topLeft = value;
                    this.OnPropertyChanged("TopLeft");
                }
            }
        }

        public double Diameter
        {
            get
            {
                return this.diameter;
            }
            set
            {
                if (this.diameter != value)
                {
                    this.diameter = value;
                    this.OnPropertyChanged("Diameter");
                }
            }
        }


    }
}
